#include "ZMysql.h"
#include <iostream>

int main() {
    // 创建 ZMysql 对象
    mysqlcpp::ZMysql mysql;

    // 连接到 MySQL 数据库
    const char* host = "localhost";
    unsigned short port = 3306;
    const char* db = "your_database";
    const char* user = "your_username";
    const char* password = "your_password";

    if (!mysql.connect(host, port, db, user, password)) {
        std::cerr << "Failed to connect to MySQL server." << std::endl;
        return 1;
    }

    // 执行查询语句
    const char* query = "SELECT * FROM your_table;";
    if (!mysql.execute(query, strlen(query))) {
        std::cerr << "Failed to execute query." << std::endl;
        mysql.disconnect();
        return 1;
    }

    // 获取查询结果
    if (!mysql.store_result()) {
        std::cerr << "Failed to store query result." << std::endl;
        mysql.disconnect();
        return 1;
    }

    // 打印查询结果
    MYSQL_ROW row;
    while ((row = mysql.fetch_row())) {
        // 假设查询结果只有一列
        std::cout << "Value: " << row[0] << std::endl;
    }

    // 释放查询结果
    mysql.free_result();

    // 断开与数据库的连接
    mysql.disconnect();

    return 0;
}
